<?php

namespace App\Http\Controllers\admin;

use App\Dao\BusinessesDao;
use App\Services\Code;

class BusinessController extends BaseController
{

    public function businesses()
    {
        if(getIsHasPage()){
            $params = request()->all();
            return Code::message('',200,BusinessesDao::businesses($params));
        }
        return view('admin.businesses.businesses');
    }

    public function add()
    {
        if(isPost()){
            $params = request()->all();
            BusinessesDao::add($params);
            return Code::message('',200);
        }
        return view('admin.businesses.add');
    }

    public function edit()
    {
        if(isPost()){
            $params = request()->all();
            BusinessesDao::update($params);
            return Code::message('',200);
        }
        $info = BusinessesDao::info(request()->all());
        return view('admin.businesses.edit',[
            'info'=>$info
        ]);
    }

    public function delete()
    {
        $params = request()->all();
        BusinessesDao::delete($params);
        return Code::message('删除成功',200);
    }
}
